package com.chj.jz.dp.class01;

public class Code03_JumpGame {
	public static boolean canJump(int[] A) {
		int n = A.length;
		boolean[] f = new boolean[n];

		f[0] = true;
		int i, j;
		for (j = 1; j < n; j++) {
			for (i = 0; i < j; i++) {
				if (f[i] && i + A[i] >= j) {
					f[j] = true;
					break;
				}
			}
		}

		return f[n - 1];
	}

	public static void main(String[] args) {
		{
			int[] arr = new int[] { 2, 3, 1, 1, 4 };
			System.out.println(canJump(arr));
		}
		{
			int[] arr = new int[] { 3, 2, 1, 0, 4 };
			System.out.println(canJump(arr));
		}
	}
}
